package jwr.basic;

import java.util.Scanner;

public class CalrendarV1 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int year,i,j,dayWeek,day;
		
		System.out.println("년도를 입력해 주세요.");
		
		year = sc.nextInt();
		
		dayWeek =((((year-1)*365 + (year-1)/4-(year-1)/100+(year-1)/400) % 7)+1);
		
		System.out.println("\t\t    January "+year);
		System.out.println("------------------------------------------------------");
		System.out.println("Sun\tMon\tTue\tWed\tFri\tMon\tSat");
		/*i = 1;
		day = 1;
		while(i<=6){
			j = 1;
			while(j<=7){
				if(i==1 && j<=dayWeek){
					System.out.print(" \t");
				}else if(j==7){
					System.out.println(day+"\t");
					day++;
				}else if(day ==31){
					System.out.println(day);
					i++;
					break;
				}else{
					System.out.print(day+"\t");
					day++;
				}
				j++;
			}
			i++;
		}*/
		if(dayWeek != 7){
			for(i = 1 ; i <= dayWeek;i++){
				System.out.print("\t");
			}
		}
		
		for(i = 1 ; i <= 31; i++){
			if((dayWeek+i)%7 == 0){
				System.out.println(i+ "\t");
			}else{
				System.out.print(i+"\t");
			}
		}
	}

}
